<?php

namespace app\admin\model;

use think\Model;

class Page extends Model
{
    // 表名
    protected $name = 'page';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    
    // 追加属性
    protected $append = [
        'category_id_text'
    ];

    public function getCategoryListFormat(){
        $model = model('app\common\model\Category');
        $data = $model->getCategoryArrayFormat('page');
        return $data;
    }




    public function getCategoryIdTextAttr($value, $data)
    {
        $value = $value ? $value : $data['category_id'];
        $list = $this->getCategoryListFormat();
        return isset($list[$value]) ? $list[$value] : '';
    }


    

    







}
